﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Controls;
using System.Windows;
using System.Windows.Input;

namespace MiApp {
    class MiLabel:Label {


          public static RoutedUICommand MiComando;
          public static DependencyProperty MyProperty;
       public static RoutedUICommand Mc {

           get {
               return MiComando;
           }
       }
        
       public int My {
           get { return (int)((object)MyProperty); }
           set { SetValue(MyProperty, value); }
       }

        public static RoutedEvent MiMouse = EventManager.RegisterRoutedEvent("MiMouseEvt",RoutingStrategy.Bubble,typeof(RoutedEventHandler),typeof(MiLabel)) ;

        static MiLabel() {
            MyProperty = DependencyProperty.Register("My", typeof(int), typeof(MiLabel));
            MiComando = new RoutedUICommand("Mc", "Mc", typeof(MiLabel));
           MiComando.InputGestures.Add(new KeyGesture(Key.A,ModifierKeys.Alt));

            RoutedEventHandler rh = new RoutedEventHandler(staticHandler);
            EventManager.RegisterClassHandler(typeof(MiLabel), MiMouse, rh);
        }

        public event RoutedEventHandler MiMouseEvt {
            add { AddHandler(MiMouse, value); }
            remove { RemoveHandler(MiMouse,value);}
        }


        protected override void OnMouseEnter(System.Windows.Input.MouseEventArgs e) {
            RaiseEvent(new RoutedEventArgs(MiMouse));
        }

        private static void staticHandler(object o, RoutedEventArgs r){

            MessageBox.Show("Handler Static");
        }
        public void MyPropertyChanged(Object o, RoutedEventArgs r) {
            MessageBox.Show("Mi propiedad cambio");
        }
    }
}
